<template>
  <div class="app-container">
    <template>
      <div class="right-detail">
        <div class="cbox">
          <el-form
            class="form"
            :model="flt"
            ref="flt"
            :rules="rules"
            :inline="true"
            size="mini"
          >
                <el-form-item label="类型编号:" prop="rvDomain">
                  <el-input maxlength="4"
                    v-model="flt.rvDomain"
                    @keyup.native="checkCode"
                    @change="uppercase('rvDomain')"
                    style="width: 100%"
                    placeholder="请输入类型编号"
                    clearable
                  ></el-input>
                </el-form-item>
              
              
                <el-form-item label="类型名称:" prop="rvName">
                  <el-input
                    v-model="flt.rvName"
                    placeholder="请输入类型名称"
                    style="width: 100%"
                    clearable
                  ></el-input>
                </el-form-item>
              
              
                <el-form-item label-width="10px">
                  <el-button @click="searchType" type="primary">查询</el-button>
                </el-form-item>
              
          </el-form>
        </div>
        <split-pane split="horizontal" v-on:resize="resize">
          <!-- 上半部分 -->
          <template slot="paneL">
            <div class="top-type" ref="topType">
              <div class="btn-area" ref="btnArea">
                <!-- <div v-for="(item,index) in grandson" :key='index'>
                  <el-button v-if="item.MDL_CODE === 'addtype'" size="mini" type="primary" plain @click="addRefType">新增</el-button>
                  <el-button v-if="item.MDL_CODE === 'edittype'" size="mini" type="primary" plain @click="editRefType">编辑</el-button>
                  <el-button v-if="item.MDL_CODE === 'deletetype'" size="mini" type="primary" plain @click="delRefType">删除</el-button>
                </div>-->
                <el-button plain size="mini" type="primary" v-if="isAuth('add')" @click="addRefType"
                  >新增</el-button
                >
                <el-button plain size="mini" type="primary" v-if="isAuth('edit')" @click="editRefType"
                  >编辑</el-button
                >
                <el-button plain size="mini" type="primary" v-if="isAuth('del')" @click="delRefType"
                  >删除</el-button
                >
              </div>

              <!-- 状态（E-启用 N-未启用 D-停用） -->
              <el-table
                :data="TypeList"
                :height="typeHeight"
                highlight-current-row
                @row-click="getCurrentTypeRow"
                border
                :header-cell-style="{ textAlign: 'center' }"
                :cell-style="{}"
              >
                <el-table-column size="mini" show-overflow-tooltip type="index" :index="indexMethodType" label="序号" align="center" width="60" ></el-table-column>
                <!--绑定中英文  -->
                <el-table-column size="mini" show-overflow-tooltip prop="rvDomain" align="center" label="类型编号"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvName" align="center" label="类型名称" ></el-table-column>
                <el-table-column size="mini"  label="有效标识"  width="85">
                  <template slot-scope="scope">
                    <div style="text-align: center;" v-if="scope.row.rvIsvalid == 'Y'">
                      <el-checkbox v-model="checkedY" disabled></el-checkbox>
                    </div>
                    <div  style="text-align: center;" v-if="scope.row.rvIsvalid == 'N'">
                      <el-checkbox v-model="checkedN" disabled></el-checkbox>
                    </div>
                  </template>
                </el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvInsertuser" align="center"  label="创建人"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvInsertdt" align="center" label="创建时间"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvLstupduser" align="center" label="修改人"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvLstupddt" align="center" label="修改时间"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip header-align="left" align="center" prop="rvRemark" label="备注"></el-table-column>
              </el-table>
              <div>
                <el-pagination
                  class="pagination"
                  small
                  background
                  ref="pagination"
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="Pagination.currentPage"
                  :page-sizes="Pagination.pageSizeList"
                  :page-size="Pagination.pageSize"
                  :layout="Pagination.layout"
                  :total="Pagination.total"
                ></el-pagination>
              </div>
            </div>
          </template>

          <!-- 下半部分 -->
          <template slot="paneR">
            <div class="codeNumberCode" style="background-color: #fff;">
              代码详情
            </div>
            <div
              class="bottom-code"
              ref="bottomCode"
              style="background-color: #fff;"
            >
              <div class="btn-area" ref="detlArea">
                <!-- <div v-for="(item,index) in grandson" :key='index'>
                        <el-button v-if="item.MDL_CODE === 'addcode'" size="mini" type="primary" plain @click="addRefCode">新增</el-button>
                        <el-button v-if="item.MDL_CODE === 'editcode'" size="mini" type="primary" plain @click="editRefCode">编辑</el-button>
                        <el-button v-if="item.MDL_CODE === 'deletecode'" size="mini" type="primary" plain @click="delRefCode">删除</el-button>
                </div>-->
                <el-button plain size="mini" type="primary" v-if="isAuth('add')" @click="addRefCode">新增</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('edit')" @click="editRefCode">编辑</el-button>
                <el-button plain size="mini" type="primary" v-if="isAuth('del')" @click="delRefCode">删除</el-button
                >
              </div>
              <el-table
                :height="detlHeight"
                :data="currentCodeList"
                highlight-current-row
                @row-click="getCurrentCodeRow"
                border
                :header-cell-style="{
                  textAlign: 'center'
                }"
                :cell-style="{}"
                >
                <el-table-column show-overflow-tooltip type="index" :index="indexMethodDet" label="序号" width="60" align="center"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip  width="180" align="center" prop="rvLowValue" label="代码编号"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip width="180" align="center" prop="rvCmeaning" label="代码名称"></el-table-column>
                <el-table-column size="mini"  width="180"  align="center" label="有效标志">
                     <!--有效标示（Y-是 N-否）-->
                  <template slot-scope="scope">
                    <div v-if="scope.row.rvIsvalid == 'Y'">
                      <el-checkbox v-model="checkedY" disabled></el-checkbox>
                    </div>
                    <div v-if="scope.row.rvIsvalid == 'N'">
                      <el-checkbox v-model="checkedN" disabled></el-checkbox>
                    </div>
                  </template>
                </el-table-column>

                <el-table-column size="mini" show-overflow-tooltip prop="rvInsertuser"  align="center" label="创建人"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvInsertdt" align="center" label="创建时间"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvLstupduser" align="center" label="修改人"></el-table-column>
                <el-table-column size="mini" show-overflow-tooltip prop="rvLstupddt" align="center" label="修改时间"></el-table-column>
              </el-table>
              <div>
                <el-pagination
                  class="pagination"
                  small
                  background
                  @size-change="handleSizeChangeA"
                  @current-change="handleCurrentChangeA"
                  :current-page="currentPage"
                  :page-sizes="[30, 60, 90, 120]"
                  :page-size="30"
                  layout="sizes, prev, pager, next, jumper, total"
                  :total="pageTotal">
                </el-pagination>
              </div>
            </div>
          </template>
        </split-pane>
      </div>
    </template>

     <!-- 代码分类dialog -->
    <el-dialog
      width="700px"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      v-el-drag-dialog
      :title="$t(TypeMap[TypeDialogStatus])"
      :visible.sync="RefTypeDialogVisible"
      v-if="RefTypeDialogVisible"
      :before-close="handleTypeDialogClose">
      <el-form
        label-position="right"
        :model="RefTypeData"
        ref="RefTypeData"
        :rules="RefTypeDataRules"
        label-width="10rem"
        size="mini"
      >
        <el-row :gutter="20">
          <el-col :span="22">
            <el-form-item prop="rvDomain" label="类型编号：">
              <el-input
                maxlength="8"
                :disabled="disableType"
                v-model="RefTypeData.rvDomain"
                @keyup.native="typecheck"
                @change="typeuppercase('rvDomain')"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item prop="rvName" label="类型名称：">
              <el-input
                maxlength="32"
                :disabled="disableType"
                v-model="RefTypeData.rvName"
              ></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="22">
            <el-form-item prop="rvIsvalid" label="有效标志：">
              <el-radio-group v-model="RefTypeData.rvIsvalid">
                <el-radio label="Y">是</el-radio>
                <el-radio label="N">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item prop="rvRemark" label="备注：">
              <el-input
                type="textarea"
                :autosize="{ minRows: 3 }"
                maxlength="128"
                v-model="RefTypeData.rvRemark"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="guanbi">关闭</el-button>
         <el-button size="mini" type="primary" @click="commitType">保存</el-button>
        
       
      </div>
    </el-dialog>

    <!-- 代码详情 dialog -->
    <el-dialog
      width="40%"
      :close-on-click-modal="false"
      v-el-drag-dialog
      :title="$t(CodeMap[CodeDialogStatus])"
      :visible.sync="RefCodeDialogVisible"
      v-if="RefCodeDialogVisible"
      :before-close="handleCodeDialogClose">
      <el-form
        label-position="right"
        :model="RefCodeData"
        ref="RefCodeData"
        :rules="RefCodeDataRules"
        label-width="10rem"
        size="mini"
      >
        <el-row :gutter="20">
          <el-col :span="22">
            <el-form-item prop="rvDomain" label="代码类型：" >
              <el-select
                disabled
                v-model="RefCodeData.rvDomain"
                filterable
                placeholder="代码类型"
                size="mini"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in rleTypes"
                  :value="item.rvDomain"
                  :key="index"
                  :label="item.rvName"
                  :title="item.rvName"
                >
                  <!-- <span style="float: left">{{ item.RV_DOMAIN }}</span>
                  <span style="float: right; font-size: 13px">{{ item.RV_NAME }}</span>-->
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="22">
            <el-form-item prop="rvLowValue" label="代码编号：">
              <el-input
                maxlength="4"
                v-model="RefCodeData.rvLowValue"
                :disabled="CodeRVDOMAIN"
                @keyup.native="codecheck"
                @change="codeuppercase('rvLowValue')"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item prop="rvCmeaning" label="代码名称：">
              <el-input maxlength="32" v-model="RefCodeData.rvCmeaning"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="22">
            <el-form-item prop="rvIsvalid" label="有效标志：">
              <el-radio-group v-model="RefCodeData.rvIsvalid">
                <el-radio label="Y">是</el-radio>
                <el-radio label="N">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div slot="footer" class="dialog-footer">
        <el-button size="mini" @click="guanbi">关闭</el-button>
        <el-button size="mini" type="primary" @click="commitCode">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  codeTableListb,
  addCodeTable,
  editCodeTable,
  delCodeTable,
  codeTableListA,
  addCodeTableA,
  addCodeTableXL,
  editCodeTableA,
  delCodeTableA,
} from '@/request/api'
import resizeMixin from '@/mixins/resize'
import isAuth from '@/mixins/buttonAuth'
import paginationMixin from '@/mixins/pagination'
import store from '../../../../store'
export default {
  mixins: [resizeMixin,paginationMixin,isAuth],
  data() {
    var RVNAME = (rule, value, callback) => {
      // 获得字符串实际长度，中文2，英文1
      var realLength = 0,
        len = value.length,
        charCode = -1
      for (var i = 0; i < len; i++) {
        charCode = value.charCodeAt(i)
        if (charCode >= 0 && charCode <= 128) realLength += 1
        else realLength += 2
      }
      if (realLength > 32) {
        return callback(new Error('最多为32位'))
        // this.companyName = cutstr(this.companyName, 60);
      } else {
        return callback()
      }
    }
    var RVREMARK = (rule, value, callback) => {
      // 获得字符串实际长度，中文2，英文1
      var realLength = 0,
        len = value.length,
        charCode = -1
      for (var i = 0; i < len; i++) {
        charCode = value.charCodeAt(i)
        if (charCode >= 0 && charCode <= 128) realLength += 1
        else realLength += 2
      }
      if (realLength > 128) {
        return callback(new Error('最多为128位'))
        // this.companyName = cutstr(this.companyName, 60);
      } else {
        return callback()
      }
    }
    return {
      currentPage:1,
      pageSize:30,
      pageTotal:0,

      currentRow: '',
      codeentRow: '',
      typeHeight: -1,
      detlHeight: -1,
      CodeRCTUUID: false,
      CodeRVDOMAIN: false,
      checkedY: true,
      checkedN: false,
      flt: {
        rvDomain: '',
        rvName: ''
      },
      copyDomain: '',
      copyName: '',
      rleTypes: [],
      TypeMap: {
        updateType: 'baseCode.editClassify',
        createType: 'baseCode.addClassify'
      },
      CodeMap: {
        updateCode: 'baseCode.editCode',
        createCode: 'baseCode.addCode'
      },
      TypeDialogStatus: '',
      CodeDialogStatus: '',
      currentNode: {},
      currentType: {},
      TypeList: [],
      currentCodeList: [],
      currentCode: {},
      RefTypeDialogVisible: false, // 代码分类 Dialog
      RefCodeDialogVisible: false, // 基础代码 Dialog
      // 代码分类
      RefTypeData: {}, // 代码分类 dialog内的form([A-Z]|\d)[0-9a-zA-Z]
      rules: {
        RV_DOMAIN: [
          { min: 1, max: 4, message: '至多输入4 个字符', trigger: 'change' },
          {
            pattern: /^([^\u4e00-\u9fa5])+$/,
            message: '禁止输入中文',
            trigger: 'change'
          }
        ],
        RV_NAME: [
          { validator: RVNAME, trigger: 'change' },
          {
            pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
            message: '只能输入中文字母数字',
            trigger: 'change'
          }
        ]
      },
      RefTypeDataRules: {
        rvDomain: [
          // { validator: RVDOMAIN, trigger: 'change' },
          { min: 1, max: 8, message: '至多输入8个字符', trigger: 'change' },
          { required: true, message: '请填写类型编号', trigger: 'blur' },
          // {
          //   pattern: /^([^\u4e00-\u9fa5])+$/,
          //   message: '禁止输入中文',
          //   trigger: 'change'
          // }
        ],
        rvName: [
          { required: true, message: '请填写类型名称', trigger: 'blur' },
          { validator: RVNAME, trigger: 'change' },
          {
            pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
            message: '只能输入中文字母数字',
            trigger: 'change'
          }
        ],
        rvIsvalid: [
          { required: true, message: '请选择有效标志', trigger: 'blur' }
        ],
        rvRemark: [{ validator: RVREMARK, trigger: 'change' }]
      },
      // 基础代码
      RefCodeData: {}, // 代码分类 dialog内的form
      RefCodeDataRules: {
        rvDomain: [
          { required: true, message: '请选择代码类型', trigger: 'change' }
        ],
        rvLowValue: [
          { min: 1, max: 4, message: '至多输入4个字符', trigger: 'change' },
          {
            pattern: /^([^\u4e00-\u9fa5])+$/,
            message: '禁止输入中文',
            trigger: 'change'
          },
          { required: true, message: '请填写代码编号', trigger: 'blur' }
        ],
        rvCmeaning: [
          { required: true, message: '请填写代码名称', trigger: 'blur' },
          { validator: RVNAME, trigger: 'change' },
          // {
          //   pattern: /^([0-9a-zA-Z\u4e00-\u9fa5])+$/,
          //   message: '只能输入中文字母数字',
          //   trigger: 'change'
          // }
        ],
        rvIsvalid: [
          { required: true, message: '请选择有效标志', trigger: 'blur' }
        ]
      }
    }
  },
  created() {
    this.resize = () => {
      this.typeHeight = this.$refs.topType.offsetHeight - 80
      // 70
      this.detlHeight = this.$refs.bottomCode.offsetHeight - 140
      // 130
    }
  },
  mounted(){

  },
  beforeMount() {
    this.refreshList()
  },
  computed: {
    grandson() {
      var dataList = []
      var number
      var arr = this.$route.path.split('/')
      number = arr.length - 1
      dataList = this.$store.state.user.permList
      for (var i = 0; i < dataList.length; i++) {
        for (var f = 0; f < dataList[i].Children.length; f++) {
          if (dataList[i].Children[f].MDL_CODE == arr[number]) {
            return dataList[i].Children[f].Grandson
          }
        }
      }
      return []
    },
    disableType() {
      return this.TypeDialogStatus === 'updateType'
    }
  },
  methods: {
    checkCode() {
      this.flt.RV_DOMAIN = this.flt.RV_DOMAIN.replace(/[^a-zA-Z]/g, '')
    },
    typecheck() {
      this.RefTypeData.RV_DOMAIN = this.RefTypeData.RV_DOMAIN.replace(
        /[^a-zA-Z]/g,
        ''
      )
    },
    codecheck() {
      this.RefCodeData.RV_DOMAIN = this.RefCodeData.RV_DOMAIN.replace(
        /[^a-zA-Z]/g,
        ''
      )
    },
    uppercase(key) {
      this.$refs.typePagination.lastEmittedPage = 1
      this.$refs.codePagination.lastEmittedPage = 1
      this.flt[key] = this.flt[key].toUpperCase()
    },
    // typeuppercase(key) {
    //   this.RefTypeData[key] = this.RefTypeData[key].toUpperCase()
    // },
    codeuppercase(key) {
      this.RefCodeData[key] = this.RefCodeData[key].toUpperCase()
    },
    getFltType() {
      addCodeTableXL({}).then(res => {
        if (res.success === '1') {
          this.rleTypes = res.data.FTKJWLHYPT
        }
      })
    },
    searchType() {
      this.copyDomain = this.flt.rvDomain
      this.copyName = this.flt.rvName
      this.$refs.flt.validate(valid=>{
        if(valid){
          this.getList(this.Pagination.currentPage,this.Pagination.pageSize,this.updatePaginationTotal)
        }
      })
    },
    //获取列表
    getList(currentPage, pageSize, updateTotal) {
      this.currentCodeList = []
      codeTableListb({
        rvDomain:this.copyDomain,
        rvName:this.copyName,
        rvTerId:store.state.user.FLT_UUID_DX_H,
        PageIndexs: this.Pagination.currentPage.toString(),
        PageSizes: this.Pagination.pageSize.toString()
      }).then(response => {
        this.TypeList = response.data
        updateTotal(Number(response.total))
      })
    },


    // 代码分类 -- 添加
    addRefType() {
      this.TypeDialogStatus = 'createType'
      this.resetRefType()
      this.RefTypeDialogVisible = true
    },
    // 代码分类 -- 编辑
    editRefType() {
      if (Object.keys(this.currentType).length == 0) {
        this.$alert('请选择需要编辑的数据！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.TypeDialogStatus = 'updateType'
      this.RefTypeDialogVisible = true

      this.RefTypeData = Object.assign({}, this.currentType)
    },

    // 代码分类的dialog  先判断是 提交 or 编辑
    commitType() {
      this.$refs['RefTypeData'].validate(valid => {
        if (!valid) {
          // this.$message.error('必输项不能为空！')
          return false
        }
        if (this.TypeDialogStatus == 'updateType') {
          this.commitEditType(this.RefTypeData)
        } else if (this.TypeDialogStatus == 'createType') {
          this.commitAddType(this.RefTypeData)
        }
      })
    },

    getCurrentTypeRow(row) {
      this.currentPage=1
      this.pageSize=30
      this.pageTotal=0
      this.currentType = row
      this.RefTypeData = Object.assign({}, row)
      this.getRefCode()
    },

    // 代码分类 -- 添加--的form表单
    commitAddType(formdata) {
      addCodeTable(formdata)
        .then(response => {
          if (response.success != '1' ) {
            this.$message.error({ message: '新增失败！' })
            return
          }else{
            this.$message.success({ message: '新增成功！' })
            this.refreshList()
            this.getFltType()
            this.RefTypeDialogVisible = false
          }
        })
    },

    // 代码分类 -- 编辑--的form表单
    commitEditType(formdata) {
      editCodeTable(formdata)
        .then(response => {
          if (response.success != '1' ) {
            this.$message.error({ message: '编辑失败！' })
            return
          }else{
            this.currentRow = ''
            this.$message.success({ message: '编辑成功！' })
            this.currentType = {}
            this.refreshList()
            this.RefTypeDialogVisible = false
          }

        })
    },
    // 代码分类 -- 删除
    delRefType() {
      if (Object.keys(this.currentType).length == 0) {
        this.$alert('请选择需要删除的数据', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('你确认要删除此数据吗？', '提示', {
        closeOnClickModal: false
      })
        .then(() => {
          this.commitDelType()
        })
        .catch(() => {})
    },
    // 代码分类 -- 确认删除
    commitDelType() {
      delCodeTable(this.currentType)
        .then(response => {
          if (response.success !== '1') {
            this.$message.error({ message: '删除失败！' })
            return
          }else{
            this.$message.success({ message: '删除成功！' })
            this.refreshList()
            this.getFltType()
            this.currentRow = ''
          }

        })
    },

    // 点击基础代码表格的一行，获取到当前行的数据
    getCurrentCodeRow(row) {
      this.codeentRow = '1'
      this.currentCode = row
    },
    // 代码详情 -- 获取
    getRefCode() {
      // this.currentType
      codeTableListA({
        rvDomain:this.currentType.rvDomain,
        rvTerId:this.currentType.rvTerId,
        PageSizes:this.pageSize.toString(),
        PageIndexs: this.currentPage.toString()
      }).then(response => {
        if (response.success != '1') {
          this.$message.error({ message: '获取代码详情失败！' })
          return
        }else{
          this.codeentRow = ''
          this.currentCodeList = response.data
          this.pageTotal = Number(response.total)
        }

      })
    },
    handleSizeChangeA(val){
      this.pageSize = val
      this.getRefCode()
    },
    handleCurrentChangeA(val){
      this.currentPage = val
      this.getRefCode()
    },
    // 基础代码 -- 添加
    addRefCode() {
      if (!Object.keys(this.currentType).length) {
        this.$message.warning('请先选择一种代码类型')
        return
      }
      this.resetRefCode()
      this.$nextTick(() => {
        this.getFltType()
      })

      this.CodeDialogStatus = 'createCode'

      this.CodeRCTUUID = false
      this.CodeRVDOMAIN = false
      this.RefCodeDialogVisible = true
      this.RefCodeData.rvDomain = this.currentType.rvDomain
    },
    // 基础代码 -- 添加--的form表单
    commitAddCode(formdata) {
      addCodeTableA(formdata)
        .then(response => {
          if (response.success != '1' ) {
            this.$message.error({ message: '新增代码详情失败！' })
            return
          }else{
            this.$message.success({ message:response.data.msg })
            this.getRefCode()
            this.RefCodeDialogVisible = false
          }

        })
    },
    // 基础代码 -- 编辑codeentRow
    editRefCode() {
      if (Object.keys(this.codeentRow).length == 0) {
        this.$alert('请选择需要编辑的数据！', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.CodeDialogStatus = 'updateCode'
      this.RefCodeDialogVisible = true
      this.CodeRCTUUID = true
      this.CodeRVDOMAIN = true
      this.RefCodeData = Object.assign({}, this.currentCode)
    },

    // 基础代码 -- 编辑--的form表单
    commitEditCode() {
      editCodeTableA(this.RefCodeData)
        .then(response => {
          if (response.success != '1' ) {
            this.$message.error({ message: '新增代码详情失败！' })
            return
          }else{
            this.getRefCode(this.currentNode)
            this.$message.success({ message: '编辑代码成功！' })
            this.RefCodeDialogVisible = false
            this.codeentRow = {}
            this.refreshList()
          }

        })
    },
    guanbi(){
      this.RefTypeDialogVisible = false
      this.RefTypeData = {}
      this.RefCodeData ={}
      this.currentType = {}
      this.codeentRow = {}
      this.refreshList()
    },
    // 基础代码的dialog  先判断是 提交 or 编辑
    commitCode() {
      this.$refs['RefCodeData'].validate(valid => {
        if (!valid) {
          return false
        }
        if (this.CodeDialogStatus == 'updateCode') {
          this.commitEditCode(this.RefCodeData)
        } else if (this.CodeDialogStatus == 'createCode') {
          this.commitAddCode(this.RefCodeData)
        }
      })
    },

    // 基础代码 -- 删除
    delRefCode() {
      if (Object.keys(this.codeentRow).length == 0) {
        this.$alert('请选择需要删除的数据', '提示', {
          confirmButtonText: '确定'
        })
        return
      }
      this.$confirm('你确认要删除此数据吗？', '提示', {
        closeOnClickModal: false
      })
        .then(() => {
          this.commitDelCode()
        })
        .catch(() => {})
    },
    // 基础代码 -- 确认删除
    commitDelCode() {
      delCodeTableA(this.currentCode)
        .then(response => {
          if (response.success != '1') {
            this.$message.error({ message: '删除代码失败！' })
            return
          }else{
            this.getRefCode(this.currentNode)
            this.codeentRow = ''
            this.$message.success({ message: '删除代码成功！' })
          }

        })
    },
    handleTypeDialogClose() {
      this.RefTypeDialogVisible = false
    },
    handleCodeDialogClose() {
      this.RefCodeDialogVisible = false
    },
    // restet 代码分类
    resetRefType() {
      return (this.RefTypeData = {
        rvTerId:'-1',
        rvDomain: '',
        rvName: '',
        rvIsvalid: 'Y',
        rvType:'U',
        rvRemark: '',
      })
    },
    // restet 基础代码
    resetRefCode() {
      return (this.RefCodeData = {
        // RCT_UUID: '',
        // RV_DOMAIN: '',
        // RV_CMEANING: '',
        // RV_NAME: '',
        // RV_ISVALID: 'Y',
        rvDomain:'',
        rvTerId:'-1',
        rvLowValue:'',
        rvCmeaning:'',
        rvIsvalid:'Y',
        // rvInsertuser:'',
        // rvLstupduser:'',
      })
    },

  }
}
</script>

<style lang="scss" scoped>
.app-container {
  overflow: hidden;
  background-color: #fff;
  position: relative;
  height: 100%;
}
.tree {
  padding-right: 20px;
  font-size: 1.4rem;
}
.right-detail {
  height: 100%;
  .top-type {
    width: 100%;
    height: 100%;
    table {
      max-width: 100%;
      font-size: 1.4rem;
      // td {
      //   min-width: 170px;
      //   line-height: 3rem;
      //   padding-right: 3rem;
      // }
    }
  }
  .bottom-code {
    width: 100%;
    height: 100%;
  }
}
.codeNumberCode {
  font-size: 1.4rem;
  font-weight: 500;
  line-height: 20px;
}
// .pagination {
//   margin: 0.3rem 0;
// }
// .left-container {
//     background-color: #F38181;
//     height: 100%;
//   }

//   .right-container {
//     background-color: #FCE38A;
//     height: 200px;
//   }

//   .top-container {
//     background-color: #FCE38A;
//     width: 100%;
//     height: 100%;
//   }

//   .bottom-container {
//     width: 100%;
//     background-color: #95E1D3;
//     height: 100%;
//   }
</style>
